package net.learn.piggy.config;

import cn.test.config.MyConfiguration;
import net.learn.piggy.annotation.MyImportEnable;
import net.learn.piggy.bean.Prop;
import net.learn.piggy.domain.MyBean;
import net.learn.piggy.registrar.MyImportBeanDefinitionRegistrar;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.*;

@Import({
        MyConfiguration.class,
        MyImportBeanDefinitionRegistrar.class,
//        MyDeferredImportSelector.class,
//        MyImportSelector.class
})
@Configuration
@EnableLoadTimeWeaving
@MyImportEnable(value = true)
@PropertySource(value = "classpath:user.properties")
public class ConfigConfiguration {
    @Bean
    @Profile("dev")
    public MyBean devTestBean() {
        return new MyBean("dev");
    }

    @Bean
    @Profile("prod")
    public MyBean prodTestBean() {
        return new MyBean("prod");
    }

    @Bean
    @ConfigurationProperties(prefix = "piggy")
    public Prop prop(){
        return new Prop();
    }
}
